class Song {
  constructor(id, name, picUrl, artists, album, alias) {
    this.id = id;
    this.name = name;
    this.picUrl = picUrl;
    this.artists = artists;
    this.album = album;
    this.alias = alias;
  }
}

export function createSong(oSong) {
  if (oSong.album) {
    let { id, name, album, alias, artists, picUrl } = oSong;
    artists = artists.map(item => item.name);
    alias = alias.join(" / ");
    return new Song(id, name, picUrl, artists.join(" / "), album, alias);
  } else {
    let { name, id, picUrl, al: album, alia: alias, ar: artists, song } = oSong;
    if (song) {
      let { alias, artists, album } = song;
      artists = artists.map(item => item.name);
      alias = alias.join(" / ");
      return new Song(id, name, picUrl, artists.join(" / "), album, alias);
    } else {
      artists = artists.map(item => item.name);
      alias = alias.join(" / ");
    }
    return new Song(id, name, picUrl, artists.join(" / "), album, alias);
  }
}
